package cn.daisy.equipment.io.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import cn.daisy.equipment.io.domain.EquIo;
import cn.daisy.equipment.io.service.IEquIoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务主表Controller
 *
 * @author Kevin
 * @date 2022-10-11
 */
@RestController
@RequestMapping("/equipment/io")
public class EquIoController extends BaseController
{
    @Autowired
    private IEquIoService equIoService;

    /**
     * 查询业务主表列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:io:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquIo equIo)
    {
        startPage();
        List<EquIo> list = equIoService.selectEquIoList(equIo);
        return getDataTable(list);
    }

    /**
     * 导出业务主表列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:io:export')")
    @Log(title = "业务主表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquIo equIo)
    {
        List<EquIo> list = equIoService.selectEquIoList(equIo);
        ExcelUtil<EquIo> util = new ExcelUtil<EquIo>(EquIo.class);
        util.exportExcel(response, list, "业务主表数据");
    }

    /**
     * 获取业务主表详细信息
     */
    @PreAuthorize("@ss.hasPermi('equipment:io:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(equIoService.selectEquIoById(id));
    }

    /**
     * 新增业务主表
     */
    @PreAuthorize("@ss.hasPermi('equipment:io:add')")
    @Log(title = "业务主表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquIo equIo)
    {
        return toAjax(equIoService.insertEquIo(equIo));
    }

    /**
     * 修改业务主表
     */
    @PreAuthorize("@ss.hasPermi('equipment:io:edit')")
    @Log(title = "业务主表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquIo equIo)
    {
        return toAjax(equIoService.updateEquIo(equIo));
    }

    /**
     * 删除业务主表
     */
    @PreAuthorize("@ss.hasPermi('equipment:io:remove')")
    @Log(title = "业务主表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(equIoService.deleteEquIoByIds(ids));
    }
}
